
//
// 120127 - AH - (Garage) Created.
// 120421 - AH - Removed @Override for interface method (1.5 compatible).
//

package org.soekrat.gui.swing.motor.wheelpassingstrategy;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JDialog;

import org.soekrat.engine.Soekrat2Engine;

/**
 * <p>
 *   Dialog with 
 *   {@link WheelPassingStrategyPanel}.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
@SuppressWarnings("serial")
public final class WheelPassingStrategyDialog extends JDialog 
{
  private WheelPassingStrategyPanel m_wpsp;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param se {@link Soekrat2Engine} interfaced.
   */
  public WheelPassingStrategyDialog(Soekrat2Engine se){ buildGui(se); }
  
  private void buildGui(Soekrat2Engine se)
  {
    if (se==null)
    {
      throw new NullPointerException("se");  
    }
    
    m_wpsp=new WheelPassingStrategyPanel(se);
    //m_wpsp.setDialog(this);
    
    Container c=getContentPane();
    
    c.setLayout(new BorderLayout());
    c.add(m_wpsp, BorderLayout.CENTER);
    
    pack();
  }
  
  private static WheelPassingStrategyDialog c_dlg=null;
  
  /**
   * <p>
   *   Gets 
   *   {@link Action} to invoke a
   *   {@link WheelPassingStrategyDialog}.
   * </p>
   * @param se {@link Soekrat2Engine} interfaced.
   * @return Created.
   */
  public static Action getShowAction(final Soekrat2Engine se)
  {
    return new AbstractAction("Wheel Passing Strategy") 
    {
      public void actionPerformed(ActionEvent e) 
      {
        if (c_dlg==null) c_dlg=new WheelPassingStrategyDialog(se);
        c_dlg.setVisible(true);
        
      }
    };  
  }
  
}
